﻿using System;
using System.Management.Automation;

namespace Nivot.PowerShell.WindowsMobile.Commands
{
    [Cmdlet(VerbsCommon.Get, "WMStoreInfo")]
    public class GetWMStorageInfoCommand : WMCommandBase
    {
        protected override void EndProcessing()
        {
            var info = new PSObject();
            int freeSize = Device.StoreInfo.FreeSize;
            int storeSize = Device.StoreInfo.StoreSize;
            int percent = (freeSize/storeSize)*100;            
            
            info.Properties.Add(new PSNoteProperty("FreeStorage", freeSize));
            info.Properties.Add(new PSNoteProperty("TotalStorage", storeSize));
            info.Properties.Add(new PSNoteProperty("PercentFree", Math.Floor((double)percent)));

            info.TypeNames[0] = "WMStorageInfo"; // allow formatdata to pick up type
            WriteObject(info);
        }
    }
}